﻿@page "/Bas/Supplier/Details"
@using nERP.ViewModel.Bas.SupplierVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
            <Display @bind-Value="@Model.Entity.SupplierCode" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.SupplierName" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.ContactPerson" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.PhoneNumber" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Email" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Faxing" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.BeginPay" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.EndPay" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.TaxtRate" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Remark" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Address" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.Bank" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.TaxpayerNumber" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.BankAccount" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.LandlinePhone" ShowLabel="true" />
            <WTUploadFile @bind-Value="@Model.Entity.SupplierFile" ShowDeleteButton="false" ShowUpload="false" />
            <Display @bind-Value="@Model.Entity.CreateTime" ShowLabel="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.UpdateTime" ShowLabel="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.CreateBy" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.UpdateBy" ShowLabel="true" />
            <Display @bind-Value="@Model.Entity.IsValid" ShowLabel="true" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button OnClick="OnClose" Icon="fas fa-arrow-right-from-bracket" Text="@WtmBlazor.Localizer["Sys.Close"]" Color="Color.Info" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private SupplierVM Model = new SupplierVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Bas/Supplier/Edit", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }

    protected override async Task OnInitializedAsync()
    {


        if (id != "")
        {
            var rv = await WtmBlazor.Api.CallAPI<SupplierVM>($"/api/Bas/Supplier/{id}");
            Model = rv.Data;
        }

        await base.OnInitializedAsync();
    }
}
